﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Sahit.iSoilHotel.Portal.ServiceProxy.Common;

namespace Sahit.iSoilHotel.Portal.ServiceProxy.Tavern.Models.Room
{
    public class BuildingModel : EntityModel
    {
        private int floorCount = 0;

        public int FloorCount
        {
            get
            {
                return floorCount;
            }
            set
            {
                this.floorCount = value;
                RenderFloorOptions();
            }
        }
        public string Name { get; set; }

        public IList<SelectListItem> FloorOptions { get; set; }

        protected void RenderFloorOptions()
        {
            FloorOptions = new List<SelectListItem>(); 
            for (int i = 1; i <= floorCount; i++)
            {
                FloorOptions.Add(new SelectListItem() { Text = i.ToString(), Value = i.ToString() });
            }

            if (floorCount > 0)
                FloorOptions[0].Selected = true;
        }

        public static IList<SelectListItem> GetBuildingOptions(IList<BuildingModel> buildings)
        {
            var q = from b in buildings
                     select new SelectListItem() { Text = b.Name, Value = b.ID.ToString()};
            return q.ToList();
        }
    }
}
